import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// blcok code //区块代码
// const blockCode = {
//   '首页推荐banner': '1326445204322574337',
//   '校园首页推荐banner': '1326447478243516417',
//   '专场推荐banner': '1326733340625731586',
//   '校园专场推荐': '1326447604970217474',
//   '首页专场推荐': '1326445878015877121',
//   '专场页面专场推荐': '1326753642051141634',
//   '校园推荐企业': '1326448656293486594',
//   '首页热门企业': '1326446075647287298',
//   '推荐职位': '1326446203934269442',
//   '热门搜索': '1326453368975712257',
//   '集团动态': '1326446640032833537',
//   '面试干货': '1326446967201128450',
//   '数据报告': '1326447200278601730',
//   '招聘公告': '1326445704648515585'
// }

import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/',
    redirect: '/redirect'
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [{
      path: '/redirect/:path(.*)',
      component: () =>
        import('@/views/redirect/index')
    }]
  },
  {
    path: '/login',
    component: () =>
      import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/register',
    component: () =>
      import('@/views/register/index'),
    hidden: true
  },
  {
    path: '/browserLow',
    component: () =>
      import('@/views/error/browser-low'),
    hidden: true
  },
  {
    path: '/legalStatement',
    component: () =>
      import('@/views/info/legalStatement'),
    hidden: true
  },
  {
    path: '/userAgreement',
    component: () =>
      import('@/views/info/userAgreement'),
    hidden: true
  },
  {
    path: '/404',
    component: Layout,
    hidden: true,
    children: [{
      path: '/404',
      component: () =>
        import('@/views/error/404')
    }]
  }
]

/**
 * asyncRoutes
 * 需要根据用户角色动态加载的路由
 */
export let asyncRoutes = []

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})

const router = createRouter()

console.log(router)

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  asyncRoutes = []
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
